import {generatorDynamicRouter} from "@/router/generator-routers";

export default {
  state: {
    asyncRouters: []
  },
  mutations: {
    SET_ASYNC_ROUTER(state, routers) {
      state.asyncRouters = routers;
    }
  },
  actions: {
    asyncRouterList({commit}) {
      return new Promise((resolve, reject) => {
        generatorDynamicRouter().then(routers => {
          commit("SET_ASYNC_ROUTER", routers);
          resolve(routers);
        }).catch((err) => {
          reject(err);
        })
      })
    }
  }
}
